package com.dy.design_pattern_study.state_pattern.dome3.impl;

import com.dy.design_pattern_study.state_pattern.dome3.State;
import com.dy.design_pattern_study.state_pattern.dome3.entry.Work;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-06
 * @Content 强制下班状态
 */
public class ForcedOffDutyState extends State {

    @Override
    public void writeProgram(Work work) {
        if (work.getHour() >= 20){
            System.out.println("时间到，需要强制下班咯，work time = " + work.getHour());
            work.setState(new RestState());
            work.writeProgram();
        } else {
            //超过 21 点，就进入 睡觉 状态
            work.setState(new SleepingState());
            work.writeProgram();
        }
    }
}
